<template>
  <el-dialog class="edit-password" title="设为轮播" append-to-body :close-on-click-modal="closeOnclickModal"
             width="380px" top="3.8vh" :visible.sync="isDialogShow" @close="close">
    <el-form>
      <el-form-item :rules="yh_rules({required:true})" label="轮播图片" style="position: relative">
        <el-upload
          ref="upLoadMasterSeal"
          :limit="1"
          action="/travel/picture/updateSlideShow"
          :on-success="uploadSuccess"
          :data="uploadData"
          list-type="picture-card"
          :on-remove="handleRemove">
          <i class="el-icon-plus"></i>
        </el-upload>
        <span class="infoTips" style="position: absolute; bottom: -25px; color: #f56c6c; left: 60px">*最多只能上传1张</span>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
  import {mapGetters} from 'vuex'
  import api from '@/utils/api.js'
  export default {
    name: 'DialogSetBaner',
    components: {},
    props: {
      dialogSetBannerShow: {
        type: Boolean,
        default: false
      },
      travelInfo: {
        type: Object
      }
    },
    data () {
      return {
        isDialogShow: false,
        uploadData: {
          infoId: '',
          cancel: 0
        }
      }
    },
    computed: {
      ...mapGetters(['size', 'closeOnclickModal', 'zhiXiaShi']),
    },
    watch: {
      dialogSetBannerShow (newValue) {
        this.isDialogShow = newValue
        if (newValue) {
          this.uploadData.infoId = this.travelInfo.infoId
        }
      }
    },
    methods: {
      uploadSuccess() {
        this.$message.success('设置成功')
        this.$emit('refreshData')
        this.close()
      },
      close() {
        this.$emit('update:dialogSetBannerShow', false)
      },
    }
  }
</script>
